package ar.com.sudoku.model;

public enum SudokuNumber {

	_1((short) 1), _2((short) 2), _3((short) 3), _4((short) 4), _5(
			(short) 5), _6((short) 6), _7((short) 7), _8((short) 8), _9(
			(short) 9);

	private short value;

	SudokuNumber(short value) {
		this.value = value;
	}

	public short getValue() {
		return value;
	}
	
	public SudokuNumber next() {
		if (value == 9) {
			return SudokuNumber.valueOf("_" + 1);
		}
		return SudokuNumber.valueOf("_" +(this.value + 1));
	}
	
	public SudokuNumber previous() {
		if (value == 1) {
			return SudokuNumber.valueOf("_" + 9);
		}
		return SudokuNumber.valueOf("_" +(this.value - 1));
	}
	
	public static SudokuNumber parse(short number) {
		return SudokuNumber.valueOf("_" + number);
	}
	
	public static SudokuNumber random() {
		short randomNumber = (short) (Math.round(Math.random() * 100 % SudokuNumber._8.getValue()));
		return SudokuNumber.parse(++randomNumber);
	}

	/*
	 * @Override public boolean equals(Object obj) { if (this == obj) { return
	 * true; } if (obj == null) { return false; } if (getClass() !=
	 * obj.getClass()) { return false; } final RealNumber number = (RealNumber)
	 * obj; if (this.getValue() == null) { if (number.getValue() == null) {
	 * return true; } return false; } return
	 * this.getValue().equals(number.getValue()); }
	 */
}
